


** Bring in the data

use "$DATA_OUT/NMDB_ASMB_respondents", clear
svyset [pweight = analysis_weight]


/**********************************************************************************************
Step 1: Get results for income shocks for all defaulters
**********************************************************************************************/

* Examine income shocks among defaulters
*x92 asks if income significantly increased / stayed the same / significantly decreased
svy: tab x92a if in_default_sample==1
gen income_shock = (x91a==1) | (x92a==3)
svy: tab income_shock if in_default_sample==1

/**********************************************************************************************
Step 2: Get some basic results on CD status for different groups
**********************************************************************************************/


*** See how many borrowers etc. report payment "concerns or difficulties" 
svy: tabulate x27 if heavywgt==1 
svy: tabulate x27 if in_default_sample==1 

** Get numbers for those who went 30 DPD, 60 DPD, etc.
gen comparison_group = (heavywgt==0) & !mi(last_current_month_b4_delinq)
svy: tabulate x27 if comparison_group==1 & dpd_status==1 
svy: tabulate x27 if comparison_group==1 & dpd_status==2 
svy: tabulate x27 if comparison_group==1 & dpd_status==3 



*** Now focus on borrowers in the default sample
keep if in_default_sample==1
tab x27 // get the # of defaulters in Figure 1


********************************************************************************
* See how many CD defaulters reported at least one shock
********************************************************************************
* For the rest of this file, just keep CD defaulters
keep if x27==1


gen num_issues = 0
foreach var in a b c d e g i j {
	replace num_issues = num_issues + 1 if x31`var'==1
}

gen num_issues_incl_disaster = num_issues + (x31f==1)


* Only count "unexpected expenses" as a separate shock if the other expense shocks are not reported
replace num_issues = num_issues + 1 if  x31h==1 & x31d!=1 & x31e!=1 & x31g!=1 & x31i!=1 & x31j!=1
replace num_issues_incl_disaster = num_issues_incl_disaster  + 1 if  x31h==1 & x31d!=1 & x31e!=1 & x31g!=1 & x31i!=1 & x31j!=1 & x31f!=1

gen at_least_1_issue = num_issues>=1 & !mi(num_issues)
gen at_least_1_issue_incl_dis =  num_issues_incl_disaster>=1 & !mi( num_issues_incl_disaster)


svy: tab at_least_1_issue
svy: tab at_least_1_issue if income_shock==0

svy: tab at_least_1_issue_incl_dis 
svy: tab at_least_1_issue_incl_dis  if income_shock==0



